package api

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"strconv"
	"video/internal/model/servce"
	"video/internal/response"
)

func VideoList(c *gin.Context) {
	page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))
	pageSize, _ := strconv.Atoi(c.DefaultQuery("pageSize", "3"))

	list, err := servce.VideoList(page, pageSize)
	if err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{"message": "展示失败"})
		return
	}

	var slice []response.VideoResponse
	for _, video := range list {
		slice = append(slice, response.VideoResponse{
			Title:    video.Title,
			Video:    video.Video,
			Sex:      video.Sex,
			Age:      video.Age,
			IsStatus: video.IsStatus,
		})
	}

	c.JSON(http.StatusOK, gin.H{"message": "展示成功", "data": slice})

}
